package com.dingreading.cloud.admin.service.impl;

import com.dingreading.cloud.admin.entity.StoreContractFile;
import com.dingreading.cloud.admin.entity.table.StoreContractFileTableDef;
import com.dingreading.cloud.admin.mapper.StoreContractFileMapper;
import com.dingreading.cloud.admin.service.StoreContractFileService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 服务层实现。
 *
 * @author Administrator
 * @since 2024-11-18
 */
@Service
public class StoreContractFileServiceImpl extends BaseServiceImpl<StoreContractFileMapper, StoreContractFile, StoreContractFileTableDef> implements StoreContractFileService {

    @Override
    protected StoreContractFileTableDef getTable() {
        return StoreContractFileTableDef.storeContractFile;
    }

    @Override
    public List<StoreContractFile> listByContractId(Long contractId) {
        return getMapper().selectListByCondition(table.contractId.eq(contractId));
    }

    @Override
    public void deleteByFileIdsNotIn(Long contractId, List<Long> fileIds) {
        getMapper().deleteByCondition(table.contractId.eq(contractId).and(table.id.notIn(fileIds)));
    }

    @Override
    public int deleteByContractId(Long contractId) {
        return getMapper().deleteByCondition(table.contractId.eq(contractId));
    }

    @Override
    public List<StoreContractFile> listByContractIdIn(List<Long> contractIds) {
        return getMapper().selectListByCondition(table.contractId.in(contractIds));
    }
}
